package com.trial.personal;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URLConnection;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import org.json.*;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class WebShareActivity extends Activity {
    /** Called when the activity is first created. */
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        TextView welcome = (TextView) findViewById(R.id.welcomeText);
		welcome.setText("Service Started");
        
        final Button getButon = (Button) findViewById(R.id.buttonGetInfo);
        getButon.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent serviceIntent = new Intent();
				serviceIntent.setAction("com.trial.personal.MonitorService");
				v.getContext().startService(serviceIntent);
				
				
				
				TextView welcome = (TextView) findViewById(R.id.welcomeText);
				welcome.setText("Service Started");
				
				
				/*try {
					JSONObject obj = new JSONObject(s);
					welcome.setText(obj.getString("status"));
					JSONArray res = obj.getJSONArray("results");
					welcome.setText(res.getJSONObject(0).getString("formatted_address"));
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				*/
			}
		});
        
        
        final Button stop = (Button) findViewById(R.id.buttonStop);
        stop.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent serviceIntent = new Intent();
				serviceIntent.setAction("com.trial.personal.MonitorService");
				v.getContext().stopService(serviceIntent);
				
				
				
				TextView welcome = (TextView) findViewById(R.id.welcomeText);
				welcome.setText("Service Stopped");
			}
		});
    }
    
    

}